package activity

class RegQtyService {

    def calcRegisterQty(Long eventId) {
        def event = Event.findById(eventId)
        def registers = event.registers
        def registerQty = 0
        for (register in registers) {
            if (['正取報名','候補報名','候補補到','待審報名','報名審過'].contains(register.status)) {                
                registerQty += 1
            }
        }
        event.registerQty = registerQty
        event.updateStatus()
        event.save()
    }    
}